Skip to content

fix(server): serve only the current content address on the versioned hydration path - #3807

Merged
kojiwakayama merged 2 commits into
mainfrom
fix/inbox-276-content-addressed-hydration-urls
Aug 17, 2026
Merged

fix(server): serve only the current content address on the versioned hydration path#3807
kojiwakayama merged 2 commits into
mainfrom
fix/inbox-276-content-addressed-hydration-urls

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Problem

The versioned hydration runtime URL (/_veryfront/hydration-runtime.<hash>.js) uses immutable caching, but the dynamic handler accepted any well-formed hash and returned the current runtime bytes. That broke the content-addressing contract. A first attempt rejected every non-current hash before release-baked assets could be served.

Fix

The dynamic handler serves only the current content address. Non-current hashes fall through to StaticHandler, which serves the exact release-baked asset from dist when present. If the stored asset is absent, the static layer returns the final non-cacheable 404. GET, HEAD, and ETag behavior follow the same ownership boundary.

Testing

  • RED: four focused tests failed because the priority-300 handler returned 404 before the priority-500 static handler.
  • GREEN: the current runtime, release-baked runtime, missing asset, ETag, GET, and HEAD cases all pass.
  • deno test --preload=src/testing/preload.ts --no-check --allow-all src/server/handlers/request/prod-hydration-module.handler.test.ts src/server/handlers/request/static.handler.test.ts src/server/services/static/static-file.service.test.ts, 3 tests with 53 steps.
  • deno fmt --check src/server/handlers/request/prod-hydration-module.handler.ts src/server/handlers/request/prod-hydration-module.handler.test.ts
  • deno lint src/server/handlers/request/prod-hydration-module.handler.ts src/server/handlers/request/prod-hydration-module.handler.test.ts
  • deno check src/server/handlers/request/prod-hydration-module.handler.ts src/server/handlers/request/prod-hydration-module.handler.test.ts
  • git diff --check

Closes veryfront/veryfront-issue-inbox#276

The versioned hydration runtime URL (/_veryfront/hydration-runtime.<hash>.js)
is cached as immutable, but ProdHydrationModuleHandler accepted any
well-formed hash and answered with current-runtime bytes, so a previously
issued URL could silently change content after a runtime upgrade
(veryfront/veryfront-issue-inbox#276, incident #264).

The handler now serves a versioned path only when its hash segment matches
the content hash of the current runtime bundle; any other hash gets a
non-cacheable 404 (checked before ETag revalidation, HEAD agrees with GET).
Callers recover via the canonical unversioned path or by re-fetching the
document, whose SSR output always embeds the current hash.

Per the recorded decision, release-baked hydration runtimes are issue #277's
scope; this change covers only the globally served current-runtime paths.
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kojiwakayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Limit details: You’ve used all 3 included reviews currently available under your plan.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 89227665-8761-4c45-bae0-7838794f6d2d

📥 Commits

Reviewing files that changed from the base of the PR and between b6d2f21 and c963812.

📒 Files selected for processing (2)
  • src/server/handlers/request/prod-hydration-module.handler.test.ts
  • src/server/handlers/request/prod-hydration-module.handler.ts

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 324 1929 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f765c8d06f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/handlers/request/prod-hydration-module.handler.ts Outdated
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: c963812cdc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kojiwakayama kojiwakayama changed the title fix(server): reject stale hashes on the versioned hydration runtime path fix(server): serve only the current content address on the versioned hydration path Aug 17, 2026
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit 2ff88bd Aug 17, 2026
34 checks passed
@kojiwakayama
kojiwakayama deleted the fix/inbox-276-content-addressed-hydration-urls branch August 17, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant